package monitor

import (
	"fmt"
	"gluenet/pkg/apis"
	"gluenet/pkg/meta"
)

func ListGuids(c *apis.GlueContext) {
	var (
		err error
		ins *meta.MetricsInstancesList
	)

	kind := c.WebContext.URLParam("object")

	if err = c.DataBase.MetricsInstancesList(kind, &ins); err != nil {
		c.Logger.Errorf("query metrics guids %v", err)
		c.WebContext.JSON(apis.ResponseReqErr(fmt.Errorf("query metrics guids %v", err), nil))
		return
	}

	c.WebContext.JSON(apis.ResponseOK(ins.GuidList))
}
